package com.damai.plugins;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.citywithincity.db.Db;
import com.citywithincity.models.Models;

public abstract class BaseJob implements Job {
	
	public BaseJob() {
		try {
			Models.assignModels(this);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		try{
			doJob(context);
		}finally{
			Db.release();
		}
	}
	
	protected abstract void doJob(JobExecutionContext context) throws JobExecutionException ;
}
